package graph.geometricshapes
{
	import mx.collections.ArrayCollection;
	
	public class GeometricPolygon extends GeometricShape
	{
		public static const NAME:String = "GeometricPolygon";
		
		public override function get getName():String
		{
			return NAME;
		}
		
		[Bindable]
		private var _lines:ArrayCollection = new ArrayCollection();
		[Bindable]
		public function get lines():ArrayCollection
		{
			return this._lines;
		}
		public function set lines(value:ArrayCollection):void
		{
			this._lines = value;
		}
		
		public override function get width():Number
		{
			var result:Number = 0;
			for each(var line:GeometricLine in this.lines)
			{
				result += line.width;
			}
			return result;
		}
		public override function set width(value:Number):void
		{
			var coef:Number = value / this.width;
			for each(var line:GeometricLine in this.lines)
			{
				line.width *= coef;
			}
		}
		
		public override function get height():Number
		{
			var result:Number = 0;
			for each(var line:GeometricLine in this.lines)
			{
				result += line.height;
			}
			return result;
		}
		public override function set height(value:Number):void
		{
			var coef:Number = value / this.height;
			for each(var line:GeometricLine in this.lines)
			{
				line.height *= coef;
			}
		}		
				
		public function GeometricPolygon(width:Number=DefaultWidth, height:Number=DefaultHeight)
		{
			super(width, height);
		}
		
		// TODO: implement Area nd Perimeter getters...		
	}
}